<?php

	require_once("fta.201003310000/fta.php");
	
	fta_registerModules(
		array(
			"FTAORM/FTAORM",
			"FTAORM/FTAORMCMSContentMetadata",
			"FTAORM/FTAORMCMSBinaryData",
			"FTAORM/FTAManyToManyInterface",
			"FTATag/FTATag",
		)
	);

	abstract class _FTAORMCMSContent extends FTAORM implements FTAManyToManyInterface {
		
		static $TABLE_NAME = "content";
		static $TABLE_SEQUENCE_NAME = "contenttablesequence_seq";
		static $TABLE_PRIMARY_KEY = "documentcode";
		
		static $DEFAULT_FIELD_TYPES = array(
			'documentcode' => 'number',
			'formid' => 'number',
			'documenttypecode' => 'string',
			'categorycode' => 'string',
			'datelogged' => 'dateAsMySQLTimestamp',
			'title' => 'string',
			'shortdescription' => 'string',
			'content' => 'string',
			'documentdate' => 'dateAsMySQLTimestamp',
			'documentyear' => 'dateAsMySQLTimestamp',
			'startdate' => 'dateAsMySQLTimestamp',
			'enddate' => 'dateAsMySQLTimestamp',
			'author' => 'string',
			'authordepartment' => 'string',
			'organisationalname' => 'string',
			'authorbio' => 'string',
			'address' => 'string',
			'phone' => 'string',
			'fax' => 'string',
			'email' => 'string',
			'url' => 'string',
			'value' => 'string',
			'inhouse' => 'string',
			'restricted' => 'string',
			'headline' => 'string',
			'active' => 'string',
			'extra1' => 'string',
			'extra2' => 'string',
			'extra3' => 'string',
			'extra4' => 'string',
			'extra5' => 'string',
			'extra6' => 'string',
			'extra7' => 'string',
			'extra8' => 'string',
			'extra9' => 'string',
			'extra10' => 'string',
			'extra11' => 'string',
			'extra12' => 'string',
			'extra13' => 'string',
			'extra14' => 'string',
			'extra15' => 'string'			
		);
		
		static $DEFAULT_TABLE_FIELDS = array(
			'formid',
			'documenttypecode',
			'categorycode',
			'datelogged',
			'title',
			'shortdescription',
			'content',
			'documentdate',
			'documentyear',
			'startdate',
			'enddate',
			'author',
			'authordepartment',
			'organisationalname',
			'authorbio',
			'address',
			'phone',
			'fax',
			'email',
			'url',
			'value',
			'inhouse',
			'restricted',
			'headline',
			'active',
			'extra1',
			'extra2',
			'extra3',
			'extra4',
			'extra5',
			'extra6',
			'extra7',
			'extra8',
			'extra9',
			'extra10',
			'extra11',
			'extra12',
			'extra13',
			'extra14',
			'extra15'
		);
		
		static $DEFAULT_REQUIRED_FIELDS = array(
			'formid','documenttypecode','cmscontentmetadata'
		);
		
		static $DEFAULT_TABLE_RELATIONSHIPS = array(
			"cmscontentmetadata" => FTAORM_RELATIONSHIP_ONE_TO_ONE,
			"binarydata" => FTAORM_RELATIONSHIP_ONE_TO_MANY,
//			"tags" => FTAORM_RELATIONSHIP_MANY_TO_MANY,
		);
			
		static $DEFAULT_RELATIONSHIP_CLASSES = array(
			'cmscontentmetadata' => 'FTAORMCMSContentMetadata',
			'binarydata' => 'FTAORMCMSBinaryData',
//			'tags' => 'FTATag'
		);
			
		//static $DEFAULT_FIELD_MAP = 
		
		public $fieldMap;
		
		//need to push in the default stuff for writing the the cms content table here..
		function __construct(Zend_Db_Adapter_Abstract $zdb){
			parent::__construct($zdb);
			
			$this->primaryKey = static::$TABLE_PRIMARY_KEY;
			$this->tableName = static::$TABLE_NAME;
			$this->tableFields = static::$DEFAULT_TABLE_FIELDS;
			
			//everything at this point.. we set to string, number or dates.. as the cms is quite loose in its typing
			//we can add more rigid testing / typing in subclasses
			$this->tableFieldTypes = static::$DEFAULT_FIELD_TYPES;
			
			
			$this->tableRequiredFields= static::$DEFAULT_REQUIRED_FIELDS;	
			
			$this->tableRelationships = static::$DEFAULT_TABLE_RELATIONSHIPS;

			$this->tableRelationshipClasses = static::$DEFAULT_RELATIONSHIP_CLASSES;
			
			
			$this->fieldMap = is_array($this->fieldMap) ? $this->fieldMap : array();
		} 
		
		
		
		//need functionality here to perform filed mapping before the automatic type fangling
		
		
		
	}
